package Abstract;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: wangxin
 * Date: 2024-09-11
 * Time: 20:48
 */


 abstract class Animal {
    private String name;
    private int age;

    public Animal(String name, int age) {
        this.name = name;
        this.age = age;
    }

    abstract public  void bark();
    abstract void eat();
    public String getname(){
        return name;
    }
}
 class Dog extends Animal{
     public Dog(String name, int age) {
         super(name, age);
     }

     @Override
     public void bark() {
         System.out.println( getname() +" 正在汪汪叫！！");
     }

     @Override
     void eat() {
         System.out.println(getname() + "正在吃狗粮！！");
     }
 }
 class Cat extends Animal{
     public Cat(String name, int age) {
         super(name, age);
     }

     @Override
     public void bark() {
         System.out.println( getname() +" 正在喵喵叫！！");
     }

     @Override
     void eat() {
         System.out.println(getname() + "正在吃猫粮！！");
     }
 }
public class test1 {
    public static void main(String[] args) {
    Dog dog = new Dog("小黄",14);
    Cat cat = new Cat("小花",15);
    dog.bark();
    cat.bark();
    dog.eat();
    cat.eat();
    }

}
